@echo off
set PROJECT_NAME=example
set LSPD_MODE=disable
set DENOISE_FORCE=disable
set CHIP_TARGET=ec718s

if not "%1"=="" (
	set PROJECT_NAME=%1
)

if not "%2"=="" (
	set LSPD_MODE=%2
) else (
	if "%1" == "luatos" (
		set LSPD_MODE=enable
	) else (
		@echo LSPD_MODE not set
	)
)

if not "%4"=="" (
	set CHIP_TARGET=%4
)

if not "%5"=="" (
	set DENOISE_FORCE=%5
)

if %LSPD_MODE% == "enable" (
    set LSPD_MODE=true
) else (
    set LSPD_MODE=false
)

if %DENOISE_FORCE% == "disable" (
    set DENOISE_FORCE=false
) else (
    set DENOISE_FORCE=true
)

@echo "=============================="
@echo "AirM2M https://openluat.com"
@echo "=============================="
@echo PROJECT   : %PROJECT_NAME%  
@echo CHIP_TARGET : %CHIP_TARGET%  
@echo LSPD_MODE : %LSPD_MODE%  
@echo DENOISE_FORCE : %DENOISE_FORCE%  
@echo "=============================="

cd project/%PROJECT_NAME% 
xmake f --chip_target=%CHIP_TARGET% --lspd_mode=%LSPD_MODE% --denoise_force=%DENOISE_FORCE%
if "%3"=="-v" (
	xmake -v
) else (
	xmake
)
cd ../../
pause